function objectCopy(ob, from){
	try {
		if (typeof ob !== 'object') throw 'not object';
		if (typeof from !== 'object') throw 'not object';
		
		Object.keys(from).forEach(p => {
			ob[p] = from[p];
		})
	} catch (e) {
		logError(e);
	}

	return ob;
}

function arrayCopy(array, from) {
	try {
		if (!Array.isArray(array)) throw 'array not array';
		if (!Array.isArray(from)) throw 'from not array';
		
		array.splice(0);
		// array.push(...from);
		from.forEach(ele => {
			array.push(ele);
		})
	} catch (e) {
		logError(e);
	}

	return array;
}

function logError(msg) {
	console.error(msg);
}

function swap(a, b){
	[a, b] = [b, a];
	return [a, b];
}

export default {
	arrayCopy, logError, swap, objectCopy
}
export {
	arrayCopy, logError, swap, objectCopy
}